<template>
	<view>
	<login :is_show="is_show" @is_login='_index'></login>
		<view class="body after-navber">
			<view style="position: relative">
				<view class="user-info flex-row flex-y-center">
					<view class="flex-grow-1 flex-y-center flex-row userinfo-name">
						<view class="flex-grow-0">
							<image class="avatar"
								:src="user_info ? user_info.avatar:'/static/images/l8SQ4yeqHndgcWFP.png'">
							</image>
						</view>
						<view class="flex-grow-1">
							<text class="user-name" v-if="user_info">{{ user_info.nickname }}</text>
							<text class="user-name" @tap="login" v-else>点击登录</text>
							<view>ID:{{user_info.no}}</view>
						</view>
					</view>
				</view>
				
			</view>
			<view style="margin: -60rpx 20rpx 0">
				<view class="tuiguangbox">
					<view class="flex-y-center title">
						<image src="/static/images/HmC1fNWYZgh4yjJO.png" class="icon"></image>
						<view>我的资产</view>
					</view>
					<view class="flex-bet navbox">
						<navigator url="/pages2/share/share-team/share-team" class="item">
							<view class="num">{{scoreinfo.count}}<text>人</text></view>
							<view>我的推广</view>
						</navigator>
						<navigator url="/pages2/share/share-order/share-order" class="item">
							<view class="num">{{scoreinfo.total_score}}<text>豆</text></view>
							<view>推广收益</view>
						</navigator>
						<navigator url="/pages2/integral-mall/exchange-money/exchange-money" class="item">
							<view class="num">{{scoreinfo.score}}<text>豆</text></view>
							<view>{{money_name}}</view>
						</navigator>
					</view>
				</view>

				<view class="listbox">
					
					<navigator url="/pages2/shop/address-list/address-list" class="flex-y-center item">
						<image
							src="/static/images/LYkMjm9CTews3f4y.png"
							class="icon"></image>
						<view class="flex-grow-1">地址管理</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</navigator>
					<navigator url="/pages/agree/agree?id=3" class="flex-y-center item">
						<image src="/static/images/fOkUujMgCsipe9v2.png" class="icon"></image>
						<view class="flex-grow-1">关于我们</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</navigator>
					<navigator url="/pages2/shop/favorite/favorite" class="flex-y-center item">
						<image src="/static/images/wdsc.png" class="icon"></image>
						<view class="flex-grow-1">我的收藏</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</navigator>
					<button open-type="contact" url="/pages2/shop/address-list/address-list" class="flex-y-center item">
						<image src="/static/images/zxkf.png" class="icon"></image>
						<view class="flex-grow-1">在线客服</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</button>
					<navigator url="/pages2/shop/article-list/article-list" class="flex-y-center item">
						<image
							src="/static/images/bvMsCIRfDcEZxzkJ.png"
							class="icon"></image>
						<view class="flex-grow-1">帮助中心</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</navigator>
					<view @tap="clearStorage" class="flex-y-center item">
						<image src="/static/images/qchc.png" class="icon"></image>
						<view class="flex-grow-1">清除缓存</view>
						<image src="/static/images/hxiala.png" class="jiantou"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		My
	} from '../../../apirequest/my-model.js';
	var m = new My();
	export default {
		data() {
			return {
				money_name:this.globalData.money_name,
				is_show:true,
				user_info: false,
				signtext: '',
				sign: true,
				order_count: [],
				score_order_count: [],
				lv: 0,
				scoreinfo:''
			}
		},
		onShow() {
			this.is_show=true;
			this._index();
		},
		methods: {
			navigatorClick: function(e) {
				var t = e.currentTarget.dataset.tel;
				uni.makePhoneCall({
					phoneNumber: t
				});
			},
			grouptap: function(e) {
				var url = e.currentTarget.dataset.url;
				uni.switchTab({
					url: url
				})
			},

			_index() {
				var that = this;
				m.get_user_info((res) => {
					if (res.code == 1) {
						that.user_info = res.data
						that.signtext = res.data.bio
						that.order_count = res.data.order_count
						that.score_order_count = res.data.score_order_count
						that.lv = res.data.level
					}
				})
				m.get_score_info((res) => {
					if(res.code == 1){
						that.scoreinfo = res.data
					}
				})
			},
			shareJoin() {
				uni.showToast({
					title: '完成任意消费即可参与推广赚钱',
					duration: 2000,
					icon: 'none'
				})
			},
			//规则说明
			agree(id) {
				uni.navigateTo({
					url: "/pages/agree/agree?id=" + id
				})
			},
			//签名
			signtap() {
				this.sign = !this.sign
			},
			//签名输入
			signinput(e) {

				if (this.signtext.length > 100) {
					uni.showToast({
						title: '字数不能超过100',
						icon: 'none'
					})
					return false;
				}
				this.signtext = e.detail.value
			},
			setToName() {
				var that = this;
				m.update_user_info({
					bio: this.signtext
				}, (res) => {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					if (res.code == 1) {

					}
				})
			},
			// login() {
				
			// 	 uni.navigateTo({
			// 	 	url: "/pages/login/login"
			// 	 })
			// },
			integral_mall: function() {
				uni.switchTab({
					url: '/pages/integral-mall/index/index'
				})
			},
			clearCache: function() {
				uni.showActionSheet({
					itemList: ['清除缓存'],
					success: function(e) {
						if (0 === e.tapIndex) {
							uni.showLoading({
								title: '清除中...'
							});
							uni.getStoreData();
							setInterval(function() {
								uni.hideLoading();
							}, 1000);
						}
					}
				});
			},

			getStorageSize: function() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						console.log(res)
						console.log(res.keys);
						console.log(res.limitSize);
						let size = res.currentSize;
						if (size < 1024) {
							that.storageSize = size + ' B';
						} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
							that.storageSize = Math.floor(size / 1024 * 100) / 100 + ' KB';
						} else if (size / 1024 / 1024 >= 1) {
							that.storageSize = Math.floor(size / 1024 / 1024 * 100) / 100 + ' M';
						}
					}
				})
			},
			clearStorage: function() {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确定清除缓存吗?',
					confirmText: '立即清除',
					success(res) {
						if (res.confirm) {
							uni.clearStorageSync();
							//重新获取并显示清除后的缓存大小
							that.getStorageSize();
							
							uni.showToast({
								title: '清除成功'
							});
							
							uni.reLaunch({
								url: "/pages/shop/index/index"
							})
						}
					}
				})
			},

			callTel: function(e) {
				var t = e.currentTarget.dataset.tel;
				console.log(t)
				uni.makePhoneCall({
					phoneNumber: t
				});
			}
		}
	}
</script>

<style lang="scss">
	.user-info {
		color: #fff;
		position: relative;
		background: linear-gradient(to top, #ff597d, #fd2e5a);
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		padding: 20rpx 0 80rpx;
	}

	.user-info view {
		z-index: 1;
	}

	.user-info .user-info-bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 0;
	}

	.user-info .avatar {
		width: 130rpx;
		height: 130rpx;
		border-radius: 99999rpx;
		border: 10rpx solid #fe6b8b;
		margin: 0 24rpx;
	}

	.user-info .user-name {
		font-size: 1.2rem;
	}

	.user-info .my-address {
		background: #ff4544;
		color: #fff;
		border-radius: 999rpx 0 0 999rpx;
		padding-right: 24rpx;
	}

	.user-info .my-address image {
		width: 44rpx;
		height: 44rpx;
		margin: 16rpx;
	}

	.order-block {
		background: #fff;
		margin-bottom: 20rpx;
	}

	.order-block .my-order {
		display: block;
		border-bottom: 1rpx solid #e3e3e3;
		padding: 24rpx;
	}

	.order-block .nav-item {
		text-align: center;
		display: block;
		font-size: 9pt;
		padding: 24rpx 0;
		position: relative;
	}

	.order-block .nav-item .num-icon {
		position: absolute;
		top: 8rpx;
		left: 50%;
		margin-left: 12rpx;
		display: inline-block;
		background: #f00;
		color: #fff;
		border-radius: 999rpx;
		font-size: 7pt;
		height: 30rpx;
		line-height: 30rpx;
		white-space: nowrap;
		min-width: 30rpx;
		text-align: center;
		padding-left: 4rpx;
		padding-right: 4rpx;
	}

	.order-block .nav-item image {
		width: 60rpx;
		height: 57rpx;
		margin-bottom: 5rpx;
	}

	.option-list {
		margin-bottom: 20rpx;
	}

	.option-item {
		background: #fff;
		padding: 0 24rpx;
		display: block;
		position: relative;
	}

	.option-item .option-content {
		border-bottom: 1rpx solid #eee;
		height: 110rpx;
	}

	.option-item .option-icon {
		width: 50rpx;
		height: 50rpx;
		margin-right: 24rpx;
	}

	.option-item .option-jisntou {
		width: 12rpx;
		height: 22rpx;
	}

	button.option-item {
		font-size: inherit;
		color: inherit;
		font-family: inherit;
		border: none;
		background: #fff;
	}

	.user-level {
		margin-top: 16rpx;
		position: relative;
	}

	.user-level image {
		width: 44rpx;
		height: 44rpx;
		margin-right: 10rpx;
		margin-left: -4rpx;
	}

	.level-name {
		height: 36rpx;
		border-radius: 18rpx;
		font-size: 8pt;
		color: #fff;
		background-color: #3c3642;
		padding: 0 16rpx 0 0;
	}

	.integral-bg,
	.integral {
		height: 100rpx;
		width: 100%;
		position: absolute;
		bottom: 0;
		left: 0;
	}

	.integral-bg {
		background-color: #888;
		opacity: 0.1;
	}

	.integral {
		padding: 0 27rpx;
		color: #353535;
		font-size: 12pt;
	}

	.integral text {
		margin-left: 20rpx;
	}

	.integral image {
		width: 52rpx;
		height: 54rpx;
		margin-right: 20rpx;
	}

	.userinfo-name,
	.userinfo-addr {}

	.integral-num {
		margin-left: 20rpx;
	}

	.user-integral-arrow image {
		width: 16rpx;
		height: 26rpx;
	}

	.user-integral-go {
		font-size: 11pt;
		color: #666;
		margin-right: 20rpx;
	}

	.shadow-btn {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		padding: 0;
		margin: 0;
		background-color: rgba(0, 0, 0, 0);
		border: 0;
		border-radius: 0;
	}

	button::after {
		transform: scale(0);
	}

	.num-1 {
		color: #ffbb43;
		font-size: 13pt;
		margin-bottom: 16rpx;
	}

	.num-2 {
		color: #666;
		align-items: center;
		line-height: 1;
	}

	.wallet {
		width: 100%;
		height: 140rpx;
		margin-bottom: 20rpx;
	}

	.wallet-1 {
		background-color: #fbfbfb;
		width: 310rpx;
		height: 100%;
	}

	.wallet-2 {
		background-color: #fff;
		width: 440rpx;
		height: 100%;
	}

	.wallet-3 {
		background-color: #fff;
		width: 279rpx;
		height: 100%;
	}

	.wallet .wallet-3:last-child .flex-grow-1 {
		border-left: 1rpx solid #e2e2e2;
	}

	.option-item.style {
		width: 25%;
		padding: 24rpx;
		font-size: 9pt;
	}

	.option-item.style .option-icon {
		margin: 0;
		margin-bottom: 12rpx;
	}

	.user-info-1 {
		margin-top: 50rpx;
		background-color: #fff;
		border-radius: 10rpx;
		height: 200rpx;
		width: 700rpx;
		color: #666;
		box-shadow: 0px 0px 12rpx 1rpx #ddd;
	}

	.user-info .sysimg {
		z-index: 8;
		position: absolute;
		width: 40rpx;
		height: 40rpx;
		top: 23rpx;
		right: 27rpx;
	}

	.chenghao {
		position: relative;
		background: #3a3740;
		padding: 15rpx 20rpx;
		margin: -20rpx 20rpx 0rpx;
		border-top-left-radius: 10rpx;
		border-top-right-radius: 10rpx;
		color: #fff;
		font-size: 0.75rem;
		z-index: 9;
	}

	.chenghao .box {
		margin: 20rpx 40rpx;
		color: #fff;
	}

	.chenghao .box .classicon .icon {
		width: 60rpx;
		height: 60rpx;
	}

	.chenghao .box .classicon .line {
		width: 205rpx;
		height: 6rpx;
		background: linear-gradient(to right, #afa8a4, #bdb7b3);
	}

	.chenghao .box .classicon .active {
		background: linear-gradient(to right, #f7cfb7, #f1b48e);
	}

	.chenghao .name {
		font-size: 0.95rem;
	}

	.chenghao .classname {
		margin: 10rpx -10rpx 0 -10rpx;
	}


	.qianming {
		color: #8a8a8a;
		font-size: 0.75rem;
		margin-top: 10rpx;
	}

	.qianming .ipt {
		line-height: 42rpx;
		height: 42rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		max-width: 400rpx;
	}

	.qianming .icon {
		width: 30rpx;
		height: 30rpx;
		margin-left: 10rpx;
	}

	.entry-rules {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.5);
		z-index: 10;
		padding: 50rpx;
	}

	.rules-container {
		background: #fff;
		border-radius: 8rpx;
		overflow: hidden;
	}

	.rules-container text {
		max-width: 100%;
	}

	.rules-container .rules-btn {
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		border-top: 1rpx solid #e3e3e3;
		border-right: 1rpx solid #e3e3e3;
	}

	.rules-container .rules-btn:last-child {
		border-right: none;
	}

	.popup {
		background: rgba(0, 0, 0, 0.6);
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: 999;
	}

	.popup .box {
		position: fixed;
		width: 607rpx;
		left: 75rpx;
		text-align: center;
		height: 683rpx;
	}

	.popup .box .bg {
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		margin-top: -35rpx;
	}

	.popup .box .logobox {
		background: #fff;
		border-bottom-left-radius: 20rpx;
		border-bottom-right-radius: 20rpx;
		display: table;
		margin: 0 auto;
		width: 350rpx;
	}

	.popup .box .logobox .logo {
		width: 240rpx;
		height: 88rpx;
	}

	.popup .box .icon {
		width: 240rpx;
		height: 240rpx;
	}

	.popup .box .text {
		width: 264rpx;
		margin: 311rpx auto 0;
		color: #cfad85;
	}

	.popup .box .text .bigtext {
		font-size: 1.4rem;
		line-height: 38rpx;
		margin: 0 auto;
		font-weight: 700;
		letter-spacing: 1.5px;
	}

	.popup .close {
		margin-bottom: -718rpx;
		width: 60rpx;
		height: 60rpx;
		margin-left: 357rpx;
	}

	.tuiguangbox {
		border-radius: 10rpx;
		padding: 0 20rpx 20rpx;
		background: #fff;
		margin-bottom: 20rpx;
		position: relative;

		.title {
			padding: 10rpx 0;
			font-size: 0.95rem;

			.icon {
				width: 60rpx;
				height: 60rpx;
				margin-right: 10rpx;
			}
		}

		.navbox {
			margin-bottom: 10rpx;

			.item {
				width: 29%;
				text-align: center;
				padding: 20rpx 0;
				border-radius: 10rpx;
				box-shadow: 0px 0px 3px 2px #ffe9ee;

				.num {
					font-size: 1.2rem;
					margin-bottom: 15rpx;

					text {
						font-size: 0.75rem;
					}
				}
			}
		}
	}

	.tuiguangbox2 {
		border-radius: 10rpx;
		padding: 0 20rpx 20rpx;
		background: #fff;
		margin-bottom: 20rpx;
		position: relative;

		.title {
			padding: 10rpx 0;
			font-size: 0.95rem;
			border-bottom: 1px solid #f6f6f6;

			.icon {
				width: 60rpx;
				height: 60rpx;
				margin-right: 10rpx;
			}

			.jiantou {
				width: 30rpx;
				height: 30rpx;
			}
		}

		.navbox {
			padding: 15rpx 0;
			font-size: 0.85rem;

			.item {
				text-align: center;

				.icon {
					width: 70rpx;
					height: 70rpx;
				}

			}
		}
	}

	.listbox {
		padding: 0 15rpx;
		border-radius: 10rpx;
		background: #fff;
		margin-bottom: 20rpx;

		button {
			text-align: left;
			background: #fff;
			font-weight: 500;
			color: #333;
		}

		.item {
			padding: 15rpx 0;
			font-size: 0.85rem;
			border-bottom: 1px solid #f6f6f6;

			.icon {
				width: 60rpx;
				height: 60rpx;
				margin-right: 5rpx;
			}

			.jiantou {
				width: 30rpx;
				height: 30rpx;
			}
		}
	}
</style>
